package com.readywu.btchecker;

import java.util.Map;

import org.json.JSONObject;

import android.content.Context;

import com.androidquery.AQuery;

public class ApiDataClient extends APIConst {

    public static final String TAG = ApiDataClient.class.getSimpleName();
    private Context mContext;
    private AQuery aQuery;

    public ApiDataClient(Context context) {
        super();
        mContext = context;
        aQuery = new AQuery(context);
    }

    public static String getAbsoluteUrl(String relativeUrl) {
        return HOST + relativeUrl;
    }

    /**
     * 网络请求 GET
     * 
     * @param url
     * @param params
     * @param ajaxCallback
     */
    public void get(String url, Map<String, Object> params,
            ApiCallback<JSONObject> ajaxCallback) {

        aQuery.ajax(url, JSONObject.class, ajaxCallback);
    }

    /**
     * 网络请求 GET
     * 
     * @param url
     * @param params
     * @param ajaxCallback
     */
    public void post(String url, Map<String, Object> params,
            ApiCallback<JSONObject> ajaxCallback) {

        aQuery.ajax(url, params, JSONObject.class, ajaxCallback);
    }

}
